<template>
  <div class="n-bilst">
    <dl class="blk">
      <!-- 飙升榜表格头部 -->
      <dt class="top">
        <!-- 飙升榜图片 -->
        <div class="topPic">
          <img :src="playlist.coverImgUrl" alt="" />
          <a href="javascript:;" :title="playlist.name"> </a>
        </div>

        <div class="tit">
          <a href="javascript:;" :title="playlist.name"
            ><h3>{{ playlist.name }}</h3></a
          >
          <div class="btn">
            <a href="javascript:;" title="播放" class="s-bg s-bg-1">播放</a>
            <a href="javascript:;" title="收藏" class="s-bg s-bg-2">收藏</a>
          </div>
        </div>
      </dt>
      <!-- 各个榜的表格内容 -->
      <dd>
        <ol>
          <li v-for="(item, index) in list" :key="item.id">
            <span class="no" :class="{ noTop: index < 3 }">{{ index + 1 }}</span>
            <a href="javascript:;" class="text f-thide s-fc0" :title="item.name">
              {{ item.name }}
            </a>
            <!-- 播放，收藏，添加小按钮 -->
            <div class="operate">
              <a href="javascript:;" class="s-bg s-bg-3" title="播放"></a>
              <a href="javascript:;" class="s-bg2 s-bg-4" title="添加到播放列表"></a>
              <a href="javascript:;" class="s-bg s-bg-5" title="收藏"></a>
              <span> </span>
            </div>
          </li>
        </ol>

        <div class="more">
          <a href="javascript:;">查看全部></a>
        </div>
      </dd>
    </dl>
  </div>
</template>

<script>
export default {
  name: 'SongList',
  data() {
    return {
      // 榜单数据
      list: [],
      // 歌单信息
      playlist: ''
    }
  },
  // 从父亲获取各个榜单的ID
  props: ['listId'],
  created() {
    this.getSongList()
  },
  methods: {
    async getSongList() {
      const { data: res } = await this.$http.get('/playlist/detail', { params: { id: this.listId } })
      this.list = res.list
      // this.list = this.list.splice(0, 3)
      this.list = res.playlist.tracks
      this.list = this.list.splice(0, 10)
      this.playlist = res.playlist
      console.log(this.list)
    }
  }
}
</script>

<style scoped>
.n-bilst {
  display: flex;
  height: 472px;
  background: url(https://s2.music.126.net/style/web2/img/index/index_bill.png?3c0bc0726fb383121c00a195dc8c0ae7) no-repeat;
}
.blk {
  width: 230px;
}
.top {
  display: flex;
  height: 100px;
  padding: 20px 0 0 19px;
}
/* 头部大图片 */
.topPic {
  position: relative;
  width: 80px;
  height: 80px;
}
.topPic img {
  display: block;
  height: 100%;
  width: 100%;
}
.topPic a {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: url(https://s2.music.126.net/style/web2/img/coverall.png?5d128bd48f5bc3d2e6c8ed12823bd57c) no-repeat -145px -57px;
}
.tit {
  width: 116px;
  margin: 6px 0 0 10px;
}
/* 大榜单的按钮 */
.btn {
  display: flex;
  margin-top: 10px;
}
.btn a {
  display: block;
  width: 22px;
  height: 22px;
  margin-right: 10px;
  text-indent: -9999px;
}

.n-bilst ol {
  height: 319px;
  margin-left: 50px;
  line-height: 32px;
}
.n-bilst ol li {
  display: flex;
  position: relative;
  height: 32px;
  /* list-style: none; */
}

/* 歌单序号 */
.n-bilst ol .no {
  width: 35px;
  height: 32px;
  margin-left: -35px;
  text-align: center;
  /* color: #666; */
  font-size: 16px;
}
/* 给前三个加的红字 */
.n-bilst ol .noTop {
  color: #c10d0c;
}
.text {
  display: block;
  width: 170px;
  height: 32px;
}
.text:hover {
  width: 84px;
}
/* 影藏多余的文字 */
.f-thide {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}
/* 装着播放，收藏，添加小按钮的盒子 */
.operate {
  display: none;
  position: absolute;
  width: 82px;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  margin-top: 5px;
}
.operate a {
  display: inline-block;
  width: 17px;
  height: 17px;
  margin-right: 10px;
  /* line-height: 17px; */
  color: #000 !important;
}

ol li:hover .operate {
  display: block;
}
ol li:hover .text {
  width: 84px;
}
.more {
  height: 32px;
  margin-right: 32px;
  text-align: right;
  line-height: 32px;
}
.s-bg {
  background: url(https://s2.music.126.net/style/web2/img/index/index.png?5e09722e9fbdde4e9174d3dbaf6141bd) no-repeat 0 -9999px;
}
.s-bg2 {
  background: url(https://s2.music.126.net/style/web2/img/icon.png?1ff641d6227401251fed34060576613f) no-repeat 0 9999px;
}
/* 播放按钮 */
.s-bg-1 {
  background-position: -267px -205px;
}
/* 收藏按钮 */
.s-bg-2 {
  background-position: -300px -205px;
}
/* 榜单下面歌曲的小播放按钮 */
.s-bg-3 {
  background-position: -267px -268px;
}
/* 添加 */
.s-bg-4 {
  background-position: 0 -700px;
}
/* 收藏 */
.s-bg-5 {
  background-position: -297px -268px;
}
</style>
